const path = require('path')

module.exports = {
  entry:
    process.env.NODE_ENV === 'development'
      ? { 'site-desktop': ['./src/main.js'] }
      : {},
  module: {
    rules: [
      {
        test: /\.(eot|svg|ttf|woff|woff2)(\?\S*)?$/,
        use: { loader: 'file-loader' },
      },
      {
        test: /\.(png|jpg|jpe?g|gif)$/,
        use: [
          {
            loader: 'url-loader',
            options: { limit: 1024 * 10 },
          },
        ],
      },
      {
        test: /\.scss$/,
        use: [
          'sass-loader',
          {
            loader: 'sass-resources-loader',
            options: {
              _resources: path.resolve(__dirname, './src/scss/common.scss'),
              get resources() {
                return this._resources
              },
              set resources(value) {
                this._resources = value
              },
            },
          },
        ],
      },
    ],
  },
  externals: process.env.BUILD_TARGET === 'package' ? { axios: 'axios' } : {},
}
